<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<table>
			<tr>
				<td>张三</td>
				<td id="t2">20</td>
				<td>男</td>
			</tr>
			<tr>
				<td>李四</td>
				<td>30</td>
				<td>男</td>
			</tr>
		</table>
		<script type="text/javascript">
			var table = document.querySelector("table");
			//----------------------------------子-------------------------------------------------------
			//获取table节点对象的直接后代的节点对象(数组)
			var c1 = table.children; //[tbody]
			// console.log(c1[0]);

			var c2 = c1[0].children; //[tr,tr]
			// console.log(c2[1]);

			//----------------------------------父-------------------------------------------------------
			var td = document.querySelector("#t2");
			var tdParent = td.parentElement;
			// console.log(tdParent);

			//----------------------------------兄弟-------------------------------------------------------
			var td = document.querySelector("#t2");
			//上一个兄弟
			var tdPrevious = td.previousElementSibling;
			console.log(tdPrevious);
			//下一个兄弟
			var tdNext = td.nextElementSibling;
			console.log(tdNext);
		</script>
	</body>
</html>
